const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => {
    const content = [];
    for(let i = 0; i < 20; i++)
        content.push({
            id: `2019${i}`,
            code: `2019${i}`,
            brandCode: `00${i}`,
            dealerCode: `dealerCode${i}`,
            currency: 1,
            laborFee: 13521.21,
            materialFee: 1321.21,
            totalFee: 546451.12,
            status: 1,
            submitTime: '2020-04-26T08:19:24.962Z',
            uplpadTime: '2020-04-26T08:19:24.962Z',
            approveTime: '2020-04-26T08:19:24.962Z',
            rowVersion: 'string',
            options: ['update', 'abandon', 'send', 'exportPi', 'upload', 'confirm', 'exportCover']
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 20,
        }
    });
});

router.get('/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '20191',
                code: '20191',
                brandId: 'brandId',
                brandName: 'X品牌',
                brandCode: '品牌x',
                dealerId: 'dealerId1',
                dealerCode: 'dealerCode',
                dealerName: 'dealerName',
                currency: 1,
                country: 'country',
                laborFee: 13213.12,
                materialFee: 1231.12,
                totalFee: 12315.12,
                comment: 'comment',
                remark: 'remark',
                uplpadComment: 'uplpadComment',
                approveComment: 'approveComment',
                rowVersion: 'string',
                options: ['update', 'abandon', 'send', 'exportPi', 'upload', 'confirm', 'exportCover'],
                goodwillSettlementDetails: [
                    {
                        id: '001',
                        goodWillCode: 'goodWillCode001',
                        laborFee: 546.12,
                        materialFee: 521.12,
                        totalFee: 45613.21,
                        goodWillDetails: [
                            {
                                id: '001',
                                type: 1,
                                code: 'code001',
                                name: 'name001',
                                usedQty: 123.21,
                                price: 2135.12,
                            },
                            {
                                id: '002',
                                type: 1,
                                code: 'code002',
                                name: 'name002',
                                usedQty: 123.21,
                                price: 2135.12,
                            }
                        ]
                    },
                    {
                        id: '002',
                        goodWillCode: 'goodWillCode001',
                        laborFee: 546.12,
                        materialFee: 521.12,
                        totalFee: 45613.21,
                        goodWillDetails: [
                            {
                                id: '003',
                                type: 1,
                                code: 'code003',
                                name: 'name003',
                                usedQty: 123.21,
                                price: 2135.12,
                            },
                        ]
                    }
                ],
                attachments: [
                    {
                        fileId: '001',
                        fileName: 'fileName001'
                    }
                ]
            }
        }
    );
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '新增成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.put('/:id/send', (req, res) => {
    res.json({
        message: '下发成功'
    });
});

router.put('/:id/confirm', (req, res) => {
    res.json({
        message: '确认成功'
    });
});

router.put('/:id/upload', (req, res) => {
    res.json({
        message: '上传成功'
    });
});
router.put('/:id/exportPiExcel', (req, res) => {
    res.json({
        message: '导出成功'
    });
});

router.put('/:id/exportCoverExcel', (req, res) => {
    res.json({
        message: '导出成功'
    });
});
module.exports = router;
